package com.cskaoyan.javase.homework.primary._0basic;

import java.util.Scanner;

/**
 * 计算税收,题目这里不复制过来了
 *
 * @since 15:27
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class IfMultiBranchDemo {
    public static void main(String[] args) {
        System.out.print("请输入工资：");
        Scanner sc = new Scanner(System.in);
        // 输入工资
        double salary = sc.nextDouble();
        // 应纳税所得额
        double taxable = salary - 2000;
        if (taxable <= 0) {
            System.out.println("不用缴税，到手工资为：" + salary);
        } else {
            // 税率
            double taxRate;
            // 速算扣除数
            double deduction;
            if (taxable <= 500) {
                taxRate = 0.05;
                deduction = 0;
            } else if (taxable <= 2000) {
                taxRate = 0.1;
                deduction = 25;
            } else if (taxable <= 5000) {
                taxRate = 0.15;
                deduction = 125;
            } else if (taxable <= 20000) {
                taxRate = 0.2;
                deduction = 375;
            } else if (taxable <= 40000) {
                taxRate = 0.25;
                deduction = 1375;
            } else if (taxable <= 60000) {
                taxRate = 0.3;
                deduction = 3375;
            } else if (taxable <= 80000) {
                taxRate = 0.35;
                deduction = 6375;
            } else if (taxable <= 100000) {
                taxRate = 0.4;
                deduction = 10375;
            } else {
                taxRate = 0.45;
                deduction = 15375;
            }
            // 应纳税额
            double tax = taxable * taxRate - deduction;
            // 实际到手工资
            double salaryLeft;
            salaryLeft = salary - tax;

            System.out.println("缴纳的个人所得税为：" + tax);
            System.out.println("实际到手工资为：" + salaryLeft);
        }
    }
}
